<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{:trans('common.web_title')}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/login.css" media="all">
    <style>
        html{
            background-image: url("/static/imgs/login_bg.jpg");
        }

        .layadmin-user-login-main{
            width: 420px;
        }

        .layui-card {
            margin-bottom: 15px;
            border-radius: 2px;
            background-color: #fff;
            box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
        }

        .logo{
            width: 80px;
            height: 80px;
            border-radius: 80px;
            margin-bottom: 15px;
        }
        .layui-form-checked[lay-skin=primary] i{
            border-color:#597FC0 !important;
            background-color:#FFF !important;
            color:#597FC0 !important;
            font-weight: bold;
        }

    </style>
</head>
<script>
    //判断是否在iframe中，页面跳出iframe访问。
    if(self.frameElement && self.frameElement.tagName == 'IFRAME'){
        top.location=self.location;
    }
</script>
<body>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main layui-card">
        <!-- <form action="" method="post">-->
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <img class="logo" src="/static/imgs/logo.jpg" alt="">
            <h2>{:trans('common.title.login')}</h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                       for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required"
                       placeholder="账号" class="layui-input" autocomplete="off">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
                       placeholder="密码" class="layui-input" autocomplete="off">
                <input type="hidden" name="ttt" value="123">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
                               for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required"
                               placeholder="图形验证码" class="layui-input" autocomplete="off">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="/admin/user/verifyCode" class="layadmin-user-login-codeimg"
                                 id="vercode" title="点击刷新">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 20px;">
                <button class="layui-btn layui-btn-fluid layui-btn-normal" lay-submit lay-filter="LAY-user-login-submit">登 陆</button>
            </div>
        </div>
        <!--</form>-->
    </div>

    <div class="layui-trans layadmin-user-login-footer">
        <p style="color: white">{:trans('common.copyright')}</p>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script src="/static/js/jquery-3.3.1.min.js"></script>

<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function () {
        var $ = layui.$
            , setter = layui.setter
            , admin = layui.admin
            , form = layui.form
            , router = layui.router()
            , search = router.search;
        //监听搜索
        form.on('submit(LAY-user-login-submit)', function(data){
            dataelem = data.elem;
            $(dataelem).attr('disabled',true)
            var field = data.field;
            $.ajax({
                'url': "login",
                'data': field,
                'success': function (data) {
                    if (data.code === 0) {
                        window.location.href = data.url;
                    } else {
                        $(dataelem).attr('disabled',false)
                        layer.msg(data.msg, {icon: 5});
                        $("#vercode").click();
                    }
                },
                'dataType': 'json',//返回的格式
                'type': 'post',//发送的格式
            });
            //
        });
        form.render();
    });

    /**
     * 点击刷新验证码
     */
    $("#vercode").click(function () {
        this.src = '/admin/user/verifyCode?t='+ new Date().getTime()
    })
</script>
</body>
</html>
